import fetch from 'common/src/utils/fetch';
import UTILS from "common/src/utils/utils";

function honorCourseList() {
    return fetch({
        url: '/api/cultureservice/bclHonorModule/honorModuleList',
        method: 'get'
    });
}

function honorDirectionList(key) {
    return fetch({
        url: '/api/cultureservice/bclHonorModule/honorDirectionList?moduleId=' + key,
        method: 'get'
    });
}

/**
 * 下载模板
 */
function downTemplate() {
    return fetch({
        url: `/api/electionservice/honorPlanStds/download`,
        method: 'get',
        responseType: 'blob'
    }).then(res => {
        UTILS.downloadFile(res, '荣誉计划名单.xls', 'application/vnd.ms-excel;charset=utf-8');
    });
}

/**
 *
 * 导出荣誉计划名单
 */
function exportHonorPlanList(data) {
    return fetch({
        url: '/api/electionservice/honorPlanStds/export',
        method: 'post',
        data: data
    });
}

/**
 *
 * 导出荣誉课程选课结果
 */
function exportHonorResultList(data) {
    return fetch({
        url: '/api/electionservice/elcResult/export/honorTeachClass',
        method: 'post',
        data: data
    });
}

/**
 *
 * 导出研究生跨校区选课结果
 */
function exportCrossCampusStudentTeachClass(data) {
    return fetch({
        url: '/api/electionservice/elcResult/export/crossCampusStudentTeachClass',
        method: 'post',
        data: data
    });
}

/**
 *
 * 导出研究生跨校区选课学生名单
 */
function exportcrossCampusStudent(data) {
    return fetch({
        url: '/api/electionservice/elcCourseTake/export/crossCampusStudent',
        method: 'post',
        data: data
    });
}
/**
 *
 * 导出全部研究生跨校区选课学生名单
 */
function crossCampusAllStudentByCampus(data) {
    return fetch({
        url: '/api/electionservice/elcCourseTake/export/crossCampusAllStudentByCampus',
        method: 'post',
        data: data
    });
}
/**
 *
 * 导出某一荣誉课程的选课学生数据
 */
function exportStudListByHonorCourseCode(data) {
    return fetch({
        url: '/api/electionservice/elcCourseTake/exportStudListByHonorCourseCode',
        method: 'post',
        data: data
    });
}

/**
 *
 * 查询是否导出完成未选课学生名单
 */
function exportStatus(key) {
    return fetch({
        url: '/api/electionservice/reportManagement/result/'+key,
        method: 'get'
    });
}

/**
 *
 * 查询是否导出完成全部学生名单
 */
function exportAllStatus(key) {
    return fetch({
        url: '/api/electionservice/graduateExamMessage/resultObs/'+key,
        method: 'get'
    });
}

/**
 *
 * 添加荣誉学生
 */
function honorPlanStds(data) {
    return fetch({
        url: '/api/electionservice/honorPlanStds',
        method: 'put',
        data: data
    });
}

/**
 *
 * 删除荣誉学生
 */
function delete_(data, calendarId) {
    let datas = {};
    datas.calendarId = calendarId;
    datas.ids = data;
    return fetch({
        url: '/api/electionservice/honorPlanStds/delete',
        method: 'post',
        data: datas
    });
}
function download(data) {
    return fetch({
        url: `/api/electionservice/elcCourseTake/exportHonorList`,
        method: 'post',
        data: data,
    });
    // .then(res => {
    //     UTILS.downloadFile(res, '上课名单.xls', 'application/msword;charset=utf-8');
    // });
}

function exportHonorListByStu(data) {
    return fetch({
        url: `/api/electionservice/elcCourseTake/exportHonorListByStu`,
        method: 'post',
        data: data,
    });
}

export default {
    pageUrl:"/api/electionservice/elcCourseTake/honorPage",
    stuPageUrl:"/api/electionservice/elcCourseTake/stuHonorPage",
    findHonorCourseListUrl: '/api/electionservice/honorPlanStds/page',
    findStuInfoPageUrl:"/api/electionservice/honorPlanStds/page",
    "coursePageUrl":"/api/electionservice/elcCourseTake/coursePage",
    "uploadUrl":"/api/electionservice/elcCourseTake/upload",
    "downloadUrl":"/api/electionservice/elcCourseTake/download",
    "historyPageUrl":'/api/electionservice/elcLog/page',
    honorCourseList: honorCourseList,
    honorDirectionList: honorDirectionList,
    downTemplate: downTemplate,
    exportHonorPlanList: exportHonorPlanList,
    exportStatus: exportStatus,
    honorPlanStds: honorPlanStds,
    delete_: delete_,
    "download":download,
    exportHonorListByStu: exportHonorListByStu,
    honorTeachClassPage: "/api/electionservice/elcResult/honorTeachClassPage",
    exportHonorResultList: exportHonorResultList,
    exportStudListByHonorCourseCode: exportStudListByHonorCourseCode,
    crossCampusStudentTeachClass: "/api/electionservice/elcResult/crossCampusStudentTeachClass",
    exportCrossCampusStudentTeachClass: exportCrossCampusStudentTeachClass,
    crossCampusStudent:'/api/electionservice/elcCourseTake/crossCampusStudent',
    exportcrossCampusStudent: exportcrossCampusStudent,
    crossCampusAllStudentByCampus: crossCampusAllStudentByCampus,
    exportAllStatus: exportAllStatus
};
